package com.example.myapplication4;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

public class MemroyActivity extends AppCompatActivity {

    public RecyclerView recyclerView;
    private List<String> datas;
    private Button btn;
    private MyAdpapter myAdpapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        datas = new ArrayList<>();
        for (int i = 0;i<40;i++) {
            datas.add(i+"");
        }
        btn = findViewById(R.id.btn);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String ster =  datas.get(2);
                ster = "10";
                datas.set(2,"10");
                Toast.makeText(MemroyActivity.this,"ceshi ", Toast.LENGTH_LONG).show();
                myAdpapter.notifyItemChanged(2);

                startActivity(new Intent(MemroyActivity.this,TestOneActivity.class));
                //创建N个对象

            }
        });


        myAdpapter = new MyAdpapter(this,datas);
        recyclerView = findViewById(R.id.recyclerv);
        RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this,LinearLayoutManager.VERTICAL, false);
//        layoutManager.set
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.setAdapter(myAdpapter);

    }
}
